Imports System.Data.OleDb
'Imports System.Data.SqlClient

Public Class DBIEOConnection
    Private StrConn_IEOSVR As String

    Public Function DBIEOConnecting() As Boolean
        Dim MyResult As Boolean = False
        Try
            If MyDBIEOCn.State = ConnectionState.Closed Then
                MyDBIEOCn.Open()
                MyResult = True
            End If
        Catch ex As System.Data.SqlClient.SqlException
            ErrRecording("", "DBIEOConnection/DBIEOConnecting", ex.Message)
        End Try
        Return MyResult
    End Function

    Public Function ExecuteProcedureDBIEOSVR(ByVal _spName As String) As DataSet
        Dim ds As New DataSet
        Dim cmd As New OleDbCommand
        'Dim cmd As New SqlCommand
        Dim da As New OleDb.OleDbDataAdapter
        'Dim da As New SqlDataAdapter

        Try
            If MyDBIEOCn.State = ConnectionState.Closed Then
                MyOnlineFlg = False
                ErrRecording("", "DBIEOConnection/ExecuteProcedureDBIEOSVR", "Can not connect to SQL Local ")
                Return ds
            End If
            cmd.Connection = MyDBIEOCn
            cmd.CommandType = CommandType.Text
            cmd.CommandText = _spName
            da.SelectCommand = cmd
            da.Fill(ds)
        Catch ex As Exception
            'MessageBox.Show(ex.Message)
            ErrRecording("", "DBIEOConnection/ExecuteProcedureDBIEOSVR", ex.Message)
        Finally
            cmd.Dispose()
            da.Dispose()
        End Try
        Return ds
    End Function

    Public Function ExecuteLOCALIEOSVR(ByVal _spName As String) As Boolean
        Dim result As Boolean = False
        Dim cmd As New OleDbCommand
        'Dim cmd As New SqlClient.SqlCommand
        Try
            If MyDBIEOCn.State = ConnectionState.Closed Then
                MyOnlineFlg = False
                ErrRecording("", "DBIEOConnection/ExecuteLOCALIEOSVR", "Can not connect to SQL Local ")
                Return result
            End If

            cmd.Connection = MyDBIEOCn
            cmd.CommandType = CommandType.Text
            cmd.CommandText = _spName
            If cmd.ExecuteNonQuery <> -1 Then
                result = True
            End If
        Catch ex As Exception
            'MessageBox.Show(ex.Message)
            ErrRecording("", "DBIEOConnection/ExecuteLOCALIEOSVR", ex.Message)
        Finally
            cmd.Dispose()
        End Try
        Return result
    End Function

    'Public Function GetFormTime(ByVal ID As String) As String
    '    Dim result As String = ""
    '    Dim ds As DataSet
    '    ds = ExecuteProcedureLOCALSVR("SELECT [Outputtime] FROM [Manufacturing] WHERE [ID] = '" & ID & "'")
    '    If ds.Tables(0).Rows.Count <> 0 Then
    '        result = ds.Tables(0).Rows(0)(0)
    '    End If
    '    Return result
    'End Function

    Public Sub Disposing()
        If Not MyDBIEOCn Is Nothing Then
            If MyDBIEOCn.State = ConnectionState.Open Then
                MyDBIEOCn.Close()
            End If
            MyDBIEOCn.Dispose()
        End If
    End Sub
    Public Sub DBIEOClosing()
        If MyDBIEOCn IsNot Nothing Then
            If MyDBIEOCn.State = ConnectionState.Open Then
                MyDBIEOCn.Close()
            End If
        End If
    End Sub

    Public Sub New()
        Try


            'Dim objConn As ADODB.Connection
            'objConn = New ADODB.Connection
            'StrConn_SVR = "Provider=MSDASQL;" & _
            '"Driver={Microsoft dBase Driver (*.dbf)}; DBQ=O:\DBF\MATRAN10.DBF"

            'StrConn_SVR = "Provider={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=O:\DBF;"

            '           objConn.Open()

            'StrConn_SVR = " Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq="O:\DBF\MATRAN10.DBF";"



            '            StrConn_SVR = " Microsoft.Jet.OLEDB.4.0;" + "Data Source = O:\DBF\MATRAN10.DBF;Extended Properties =dBase IV;"

            StrConn_IEOSVR = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= N:\PL\MATTOOL\IEO\IEO-2010.mdb"
            MyDBIEOCn = New OleDbConnection(StrConn_IEOSVR)
        Catch ex As Exception
            ErrRecording("", "DataConnection/ServerConnecting", ex.Message)

        End Try
    End Sub
End Class
